import request from '@/utils/request'
const baseURL = process.env.VUE_APP_BASE_URL
export function submitTemplate(data) {
    return request({
        method: 'post',
        url: baseURL + '/superlink/api/technology/create/template',
        data
    })
}

export function submitImport(data) {
    return request({
        method: 'post',
        url: baseURL + `/superlink/api/technology/formula/import/${data.templateId}?url=${data.url.slice(4)}`,

    })
}

export function save2pdf(url) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/save2pdf',
        params: {
            url
        },
        // text/plain
        // headers: {
        //     'Content-Type': 'text/plain'
        // },
    })
}
export function submitFormula(data) {
    return request({
        method: 'post',
        url: baseURL + '/superlink/api/technology/formula/create',
        data
    })
}
export function getTemplate(params) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/templates',
        params: params
    })
}
export function getTemplateToken(token, includePDF = false) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/template/' + token,
        params: {
            includePDF: includePDF
        }
    })
}
export function getFormulaToken(token, includePDF, includeDeviceType, includeTechnology = true) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/formula/' + token,
        params: {
            includePDF: includePDF,
            includeDeviceType,
            includeTechnology
        }
    })
}
export function getTechnologyToken(token, includePDF, includeTemplate = true) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/technology/' + token,
        params: {
            includePDF: includePDF,
            includeTemplate,
        }
    })
}
export function exportTechnology(params) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/export',
        params,
        responseType: 'arraybuffer',
    })
}

export function editTemplateToken(data, token) {
    return request({
        method: 'put',
        url: baseURL + '/superlink/api/technology/update/template/' + token,
        data
    })
}
export function editFormula(data, token) {
    return request({
        method: 'put',
        url: baseURL + '/superlink/api/technology/formula/update/' + token,
        data
    })
}
export function delTechnologyToken(token) {
    return request({
        method: 'delete',
        url: baseURL + '/superlink/api/technology/technology/' + token,
    })
}
export function delFormulass(token) {
    return request({
        method: 'delete',
        url: baseURL + '/superlink/api/technology/formula/delete/' + token,
    })
}
export function delTemplateToken(token) {
    return request({
        method: 'delete',
        url: baseURL + '/superlink/api/technology/delete/template/' + token,
    })
}
export function delTechnology(token) {
    return request({
        method: 'delete',
        url: baseURL + '/superlink/api/technology/technology/delete/' + token,
    })
}
export function submitTechnology(data) {
    return request({
        method: 'post',
        url: baseURL + '/superlink/api/technology/technology/create',
        data
    })
}
export function submitTechnologyPut(data, token) {
    return request({
        method: 'put',
        url: baseURL + '/superlink/api/technology/technology/update/' + token,
        data
    })
}
export function getTechnology(params) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/technologys',
        params
    })
}
export function technologyTokens(params) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/technologyTokens',
        params
    })
}
export function getFormulass(params) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/formulas',
        params
    })
}
export function formulaTokens(params) {
    return request({
        method: 'get',
        url: baseURL + '/superlink/api/technology/formulaTokens',
        params
    })
}
export function tasks2formula(data) {
    return request({
        url: baseURL + `/superlink/api/production/tasks2formula/merge`,
        method: 'post',
        data
    })
}